<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<button onclick="closeP()">每3s关闭页面</button>
		<button onclick="foo2()" id="btn2">倒数5秒</button>
		
		<script>
			
			function closeP(){
				
				// setTimeout(代码)
				setTimeout(function(){
					close()
				},3000);
				
			}
			
			var n = 5;
			function foo2(){
				n -= 1;
				btn2.textContent = "倒数" + n + "秒";
				setTimeout(foo2,1000);
			}
			
		</script>
		
		
		
	</body>
</html>